package test;

import B3.State;
import B3.Event;
import B3.Read_source_file;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

public class B3test {
    @Test
    // 从读第一个其他字符到读字符串到读转义然后继续读字符串，最后退出字符串继续读其他字符
    void all_process_of_reading()
    {
        Read_source_file read_source_file = new Read_source_file();
        read_source_file.setstr(true); //读到第一个双引号
        read_source_file.fire(Event.toReading_str);
        State state = read_source_file.getCurrentState();
        Assertions.assertThat(state).isEqualTo(State.Reading_str);
        read_source_file.setstr(false); //当前读的不是双引号
        read_source_file.setescape(true); //读到反斜杠
        read_source_file.fire(Event.toescape_next_characher);
        state = read_source_file.getCurrentState();
        Assertions.assertThat(state).isEqualTo(State.escape_next_character);
        read_source_file.setescape(false); //当前读的不是反斜杠
        read_source_file.fire(Event.toReading_str);
        state = read_source_file.getCurrentState();
        Assertions.assertThat(state).isEqualTo(State.Reading_str);
        read_source_file.setstr(true); //读到第二个双引号
        read_source_file.fire(Event.toReading);
        state = read_source_file.getCurrentState();
        Assertions.assertThat(state).isEqualTo(State.Reading);
    }
}

